package com.zunipe.screen;

import com.zunipe.OreSim.Ore;
import com.zunipe.until.Util;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
import net.minecraft.client.gui.screen.option.OptionsScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.CyclingButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Style;

public class XrayOptionScreen extends Screen
{
    private final Screen parent;

    protected XrayOptionScreen(Screen screen)
    {
        super(new LiteralText("矿物透视设置"));
        this.parent = screen;
    }

    @Override
    protected void init()
    {
        this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, this.height / 6 + 210, 200, 20, ScreenTexts.DONE, button -> this.client.setScreen(this.parent)));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.diamond.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 25, 200, 20, new LiteralText("钻石").setStyle(Style.EMPTY.withColor(0x21F4FF)), (a, b) -> Ore.diamond.setValue(b.getSwitch())));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.emerald.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 50, 200, 20, new LiteralText("绿宝石").setStyle(Style.EMPTY.withColor(0x1BD12D)), (a, b) -> Ore.emerald.setValue(b.getSwitch())));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.gold.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 75, 200, 20, new LiteralText("金").setStyle(Style.EMPTY.withColor(0xF7E51E)), (a, b) -> Ore.gold.setValue(b.getSwitch())));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.iron.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 100, 200, 20, new LiteralText("铁").setStyle(Style.EMPTY.withColor(0xECAD77)), (a, b) -> Ore.iron.setValue(b.getSwitch())));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.copper.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 125, 200, 20, new LiteralText("铜").setStyle(Style.EMPTY.withColor(0xEF9700)), (a, b) -> Ore.copper.setValue(b.getSwitch())));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.redstone.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 150, 200, 20, new LiteralText("红石").setStyle(Style.EMPTY.withColor(0xF50717)), (a, b) -> Ore.redstone.setValue(b.getSwitch())));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.lapis.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 175, 200, 20, new LiteralText("青金石").setStyle(Style.EMPTY.withColor(0x081ABD)), (a, b) -> Ore.lapis.setValue(b.getSwitch())));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.coal.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 200, 200, 20, new LiteralText("煤"), (a, b) -> Ore.coal.setValue(b.getSwitch())));
        this.addDrawableChild(CyclingButtonWidget.builder(Util.Switch::getTranslatableName).values(Util.Switch.values()).initially(Util.Switch.get(Ore.debris.getValue())).build(this.width / 2 - 100, this.height / 6 + 210 - 225, 200, 20, new LiteralText("远古残骸").setStyle(Style.EMPTY.withColor(0xD11BF5)), (a, b) -> Ore.debris.setValue(b.getSwitch())));
    }

    @Override
    public void render(MatrixStack matrices, int mouseX, int mouseY, float delta)
    {
        this.renderBackground(matrices);
        OptionsScreen.drawCenteredText(matrices, this.textRenderer, this.title, this.width / 2, 15, 0xFFFFFF);
        super.render(matrices, mouseX, mouseY, delta);
    }
}
